package com.ztesoft.book.admin.config.shiro.handler;

import com.google.common.collect.Lists;
import org.apache.shiro.aop.AnnotationResolver;
import org.apache.shiro.aop.MethodInterceptor;
import org.apache.shiro.authz.aop.AuthenticatedAnnotationMethodInterceptor;
import org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor;
import org.apache.shiro.authz.aop.GuestAnnotationMethodInterceptor;
import org.apache.shiro.authz.aop.RoleAnnotationMethodInterceptor;
import org.apache.shiro.authz.aop.UserAnnotationMethodInterceptor;
import org.apache.shiro.spring.aop.SpringAnnotationResolver;
import org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor;

import java.util.List;


/**
 * @Description Shiro 切面类
 * @Author YangFan
 * @Date 2021-07-07 23:38
 */
public class MyAop extends AopAllianceAnnotationsAuthorizingMethodInterceptor implements MethodInterceptor {

    public MyAop() {
        List<AuthorizingAnnotationMethodInterceptor> interceptors = Lists.newArrayList();
        AnnotationResolver resolver = new SpringAnnotationResolver();
        interceptors.add(new RoleAnnotationMethodInterceptor(resolver));
        interceptors.add(new MyPermissionAnnotationMethodInterceptor(resolver));
        interceptors.add(new AuthenticatedAnnotationMethodInterceptor(resolver));
        interceptors.add(new UserAnnotationMethodInterceptor(resolver));
        interceptors.add(new GuestAnnotationMethodInterceptor(resolver));
        setMethodInterceptors(interceptors);
    }
}
